﻿Public Class frmIterator

    Private Sub frmIterator_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Output.Print("-------------------------")
        Output.Print("--Patrón Iterator:")
    End Sub

    Private Sub btnRecorrer_Click(sender As System.Object, e As System.EventArgs) Handles btnRecorrer.Click
        Dim libros As New AgregadoConcreto(Of Libro)()
        libros.add(New Libro("PatitoFeo", "123456"))
        libros.add(New Libro("El Zaraza", "111111"))
        libros.add(New Libro("Lalala mio", "999999"))

        Dim it As IteratorConcreto(Of Libro) = libros.CreateIterator()

        While (it.MoveNext())
            Output.Print(String.Format("Libro: {0}, ISBN: {1}", it.Current.Nombre, it.Current.ISBN))
        End While

    End Sub

    Private Sub btnRevistas_Click(sender As System.Object, e As System.EventArgs) Handles btnRevistas.Click
        Dim revistas As New AgregadoConcreto(Of Revista)()
        revistas.add(New Revista("Revista1", "123456"))
        revistas.add(New Revista("Revista2", "111111"))
        revistas.add(New Revista("Revista3", "999999"))

        Dim rev As IteratorConcreto(Of Revista) = revistas.CreateIterator()

        While (rev.MoveNext())
            Output.Print(String.Format("Revista: {0}, Code: {1}", rev.Current.Nombre, rev.Current.ISBN))
        End While
    End Sub
End Class